package com.cskaoyan.order.controller.hxj;

import com.cskaoyan.mall.commons.constant.SysRetCodeConstants;
import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.order.dto.CancelOrderRequest;
import com.cskaoyan.order.dto.CancelOrderResponse;
import com.cskaoyan.order.form.CancelOrderForm;
import com.cskaoyan.order.service.OrderCoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Tiger
 * @since 2022/06/17 19:51
 */

@RestController
public class OrderCancelController {

    @Autowired
    OrderCoreService orderCoreService;

    @PostMapping("/shopping/cancelOrder")
    public ResponseData cancelOrder(@RequestBody CancelOrderForm cancelOrderForm){
        CancelOrderRequest request = new CancelOrderRequest();
        request.setOrderId(cancelOrderForm.getOrderId());
        CancelOrderResponse response = orderCoreService.cancelOrder(request);
        if(SysRetCodeConstants.SUCCESS.getCode().equals(response.getCode())){
            return new ResponseUtil().setData(response);
        }
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }


}
